<template>
  <div class="app-container">
    <!--工具栏-->
    <el-dialog  title="打印预览"
                destroy-on-close
                v-dialogDrag
                close-on-press-escape
                :visible.sync="showPdf" append-to-body width="50vw">
      <j-pdf :src="pdfSrc" ></j-pdf>
    </el-dialog>
    <el-dialog
      title="请选择打印模板"
      :visible.sync="crud.printConfig.pringDialog"
      width="30%"
    >
      <jPrintConfig groupId="wareCheck"
                    v-if="crud.printConfig.pringDialog"
                    @getPrintId="crud.toPrint"
                    :isPreview="crud.printConfig.isPreview"
      ></jPrintConfig>
    </el-dialog>
    <div class="head-container">
      <!--搜索-->
      <div v-if="crud.props.searchToggle">
        <el-form size="small" label-width="70px"  v-formkey="{query:toQuery}">
          <el-row :gutter="10">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="业务日期">
                <div class="flex flex-row">
                  <el-date-picker
                    v-model="query.startTime"
                    align="right"
                    unlink-panels
                    class="fl1"
                    format="yyyy - MM - dd "
                    value-format="yyyy-MM-dd"
                    default-value
                    range-separator=""
                    placeholder="开始日期"
                  />
                  <el-date-picker
                    v-model="query.endTime"
                    align="right"
                    unlink-panels
                    class="fl1"
                    format="yyyy - MM - dd "
                    value-format="yyyy-MM-dd"
                    default-value
                    range-separator=""
                    placeholder="结束日期"
                  />
                </div>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="编码">
                <el-input v-model="query.code"/>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="盘点次数">
                <el-input-number type="number" style="width: 100%" v-model="query.checkNum" show-word-limit maxlength="10"/>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="盘点状态">
                <el-select v-model="query.isCheck" clearable style="width: 100%">
                  <el-option
                    v-for="item in dict.common_yes_or_no"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
            <el-row :gutter="10">
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="盘点人">
                <zSelect :value.sync="query.userIds" :multiple="multiple" url="api/dropDown/sysUserList" :params="{businessAttr:'3',isContact:'1,2'}"
                         style="width:  100%"/>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="仓库">
                <zSelect :value.sync="query.warehouseIds" :multiple="multiple"  url="api/dropDown/basWarehouseList"  style="width:  100%"/>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="备注">
                <el-input v-model="query.remark"/>
              </el-form-item>
            </el-col>
              <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
                <el-form-item label="商品">
                  <zSelect :value.sync="query.goodsIds"  url="api/dropDown/basGoodsList"/>
                </el-form-item>
              </el-col>
            </el-row>
          <el-row :gutter="10" style="text-align: center">
              <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
                <el-form-item label="商品品牌">
                  <zSelect :value.sync="query.goodsBrandIds"   url="api/dropDown/basGoodsBrandList" >
                  </zSelect>
                </el-form-item>
              </el-col>
              <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
                <el-form-item label="供应商">
                  <zSelect :value.sync="query.customerId"   url="api/dropDown/basCustomerList" style="width:  100%"/>
                </el-form-item>
              </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <el-form-item label="状态">
                <el-select v-model="query.orderStatus" clearable style="width: 100%">
                  <el-option
                    v-for="item in dict.common_order_status"
                    :key="item.id"
                    :label="item.label"
                    :value="item.value"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
              <rrOperation :crud="crud"/>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission">
        <el-button
          slot="left"
          class="filter-item"
          size="mini"
          type="primary"
          @click="handleClick"
          v-permission="permission.add"
        >
          新增
        </el-button>
        <el-button
          slot="left"
          class="filter-item"
          size="mini"
          type="success"
          :disabled="crud.selections.length !== 1"
          @click="crud.toDetail('wareCheckDetail',crud.selections[0].id)"
          v-permission="permission.edit"
        >修改
        </el-button>
        <el-button
          slot="right"
          class="filter-item"
          size="mini"
          type="success"
          @click="crud.doPassOrReject('PASS')"
          :loading="crud.passLoading"
          :disabled="crud.selections.length < 1"
          v-permission="permission.pass"
        >
          审核
        </el-button>
        <el-button
          slot="left"
          class="filter-item"
          size="mini"
          type="success"
          @click="orderMerge"
          :disabled="crud.selections.length < 2"
          v-permission="permission.orderMerge"
        >
          单据合并
        </el-button>
      </crudOperation>

      <vue-context-menu :contextMenuData="contextMenuData"
                        @tableConfig="tableConfig"
                        @deletedata="deletedata"></vue-context-menu>
      <!-- 表格配置 -->
      <el-dialog title="表格配置"
                 :visible.sync="tableConfigShow"
                 width="60%">
        <j-table-column-config :columns.sync="crud.header"  @tabSave="tabSave" @pit="pit" />
      </el-dialog>

      <!--表格渲染-->
      <el-table ref="table"  border
                height="700"
                show-summary
                @cell-dblclick="row=>crud.toEdit(row)"
                v-loading="crud.loading"
                :data="crud.data"
                size="small"
                style="width: 100%;"
                v-if="isShowTable"
                @header-dragend="changeColWidth"
                @contextmenu.native="showMenu"
                :summary-method="crud.sumRow"
                @row-click="crud.selectRow"
                :row-style="crud.rowClass"
                :row-class-name="crud.tableRowClassName"
                @selection-change="crud.selectionChangeHandler"
                @row-dblclick="crud.toDetail('wareCheckDetail',$event.id)">
        <el-table-column :render-header="crud.renderHeader" type="selection" width="60"/>
        <el-table-column :render-header="crud.renderHeader" type="index" width="50px" label="序号"/>
        <el-table-column
          v-if="item.visible"
          v-for="(item, index) in crud.header"
          :key="`col_${index}`"
          :prop="item.prop"
          :label="columnLabel(item)"
          :width="item.width + 'px'"
          :data-porp='item.prop'
          @contextmenu.native="showMenu"
          @header-dragend="changeColWidth"
        >
          <!-- 自定义渲染模版 -->
          <template slot-scope="scope">
            <!-- 当列key为 sort 时，渲染一个手柄icon -->
            <template v-if="item.prop =='sort'">
              <div class="handle_move">
                <i :class="scope.row['sort']" />
              </div>
            </template>
            <template v-else>
              <span v-if="item.type == 1" style="margin-left: 0px">{{scope.row[`${item.prop}`]}}</span>
              <span v-if="item.type == 2" style="margin-left: 0px">{{ parseTime(scope.row[`${item.prop}`])}}</span>
              <span v-if="item.type == 3" style="margin-left: 0px">{{ getDict(`this.dict.label.${item.dictionary}["${scope.row[item.prop]}"]`) }}</span>
            </template>
          </template>
        </el-table-column>
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('code')" prop="code" label="单据编号">-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('busDate')" prop="busDate" label="业务日期">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.busDate) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('type')" prop="type" label="盘点类型">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ dictName(dict.t_ware_check_type,scope.row.type) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('warehouseName')" prop="warehouseName" label="仓库"/>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('isCheck  ')" prop="isCheck  " label="盘点状态">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ dictName(dict.t_ware_check_type,scope.row.isCheck) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('checkNum')" prop="checkNum" label="第几次盘点" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('checkProductNum')" prop="checkProductNum" label="盘点条数"/>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('correctProductNum')" prop="correctProductNum" label="盘点正确数" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('correctRate')" prop="correctRate" label="正确率"/>-->
<!--          <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('isCheckCorrect')" prop="isCheckCorrect" label="是否盘点正确" >-->
<!--            <template slot-scope="scope">-->
<!--              <span>{{ dictName(dict.common_yes_or_no,scope.row.isCheckCorrect) }}</span>-->
<!--            </template>-->
<!--          </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('isBatchCheck')" prop="isBatchCheck" label="是否批次盘点" >-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ dictName(dict.common_yes_or_no,scope.row.isBatchCheck) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('userName')" prop="userName" label="盘点人"/>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('deptName')" prop="deptName" label="盘点部门"/>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('productCount')" prop="productCount" label="实际数量"/>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('boxCount')" prop="boxCount" label="实际箱数"/>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('sourceType')" prop="sourceType" label="来源类型">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ dictName(dict.t_ware_check_source_type,scope.row.sourceType) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('sourceCode')" prop="sourceCode" label="来源单据编号" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('printCount')" prop="printCount" label="打印次数" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('orderStatus')" prop="orderStatus" label="状态" >-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ dictName(dict.common_order_status,scope.row.orderStatus) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('remark')" prop="remark" label="备注" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('createUserName')" prop="createUserName" label="添加人" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('createTime')" prop="createTime" label="添加时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.createTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('updateUserName')" prop="updateUserName" label="修改人" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('updateTime')" prop="updateTime" label="修改时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.updateTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('auditUserName')" prop="auditUserName" label="审核人" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('auditTime')" prop="auditTime" label="审核时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.auditTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('closeUserName')" prop="closeUserName" label="关闭人" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('closeTime')" prop="closeTime" label="关闭时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.closeTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('isBatchCheck')" prop="isBatchCheck" label="是否同步" >-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ dictName(dict.common_yes_or_no,scope.row.isBatchCheck) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('closeUserName')" prop="closeUserName" label="关闭人" />-->
<!--        <el-table-column :render-header="crud.renderHeader" v-if="columns.visible('closeTime')" prop="closeTime" label="关闭时间">-->
<!--          <template slot-scope="scope">-->
<!--            <span>{{ parseTime(scope.row.closeTime) }}</span>-->
<!--          </template>-->
<!--        </el-table-column>-->
      </el-table>
      <!--分页组件-->
      <pagination/>
      <!--表单-->
      <el-dialog :close-on-click-modal="false"
                 :visible.sync="dialogVisible"
                 :title="crud.status.title"
                 width="500px">
        <el-form size="small" ref="form" :model="form" :rules="rules" label-width="120px"
                 :disabled="form.status==0">
          <el-row :gutter="10">
            <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
              <el-form-item label="是否全仓盘点" prop="isAllWarehouseCheck">
                <el-select v-model="form.isAllWarehouseCheck"   @change="changeForm"   style="width: 100%">
                  <el-option label="是" :value="1"></el-option>
                  <el-option label="否" :value="0"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
              <el-form-item label="品牌" prop="goodsBrandIds">
                <zSelect multiple :value.sync="form.goodsBrandIds" :disabled="form.isAllWarehouseCheck==1"  url="api/dropDown/basGoodsBrandList" >
                </zSelect>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
              <el-form-item label="供应商" prop="customerId">
                <zSelect :value.sync="form.customerId" :disabled="form.isAllWarehouseCheck==1" url="api/dropDown/basCustomerList" :params="{isContact:'1,2'}"
                         style="width:  100%"/>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
              <el-form-item label="商品分类">
                <treeselect
                  v-model="goodsTypeId"
                  :options="typeList"
                  :disabled="form.isAllWarehouseCheck==1"
                  placeholder="选择商品分类"
                  style="width: 100%"
                  :normalizer="normalizer"
                  :multiple="true"
                  @select="getgoodsType"
                >
                </treeselect>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
              <el-form-item label="是否批次盘点" prop="isBatchCheck"     >
                <el-select v-model="form.isBatchCheck" style="width: 100%">
                  <el-option label="是" :value="1"></el-option>
                  <el-option label="否" :value="0"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
              <el-form-item label="盘点人" prop="userId">
                <zSelect :value.sync="form.userId" url="api/dropDown/sysUserList"
                         style="width:  100%"/>
              </el-form-item>
            </el-col>
            <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
              <el-form-item label="盘点仓库" prop="warehouseId">
                <zSelect :value.sync="form.warehouseId" url="api/dropDown/basWarehouseList"  style="width:  100%"/>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="handleCancel">取消</el-button>
          <el-button :loading="crud.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
          <el-button :loading="crud.cu === 2" type="success" @click="addDirect">直接新增</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import crudwareCheck from '@/api/erp/wareCheck'
import CRUD, {presenter, header, form, crud} from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import MaterialList from "@/components/material";
import {Notification} from "element-ui";
import Treeselect from '@riophae/vue-treeselect'
import {getTypeList} from "@/api/erp/basGoodsType";

import { publicListKey } from "@/utils/key";
import {getHeaderProperties} from "@/api/erp/headerProperties";
import {tablemixins} from "@/mixins/tablemixins";
import  jTableColumnConfig  from "@/components/jTableColumnConfig/jTableColumnConfig";
import jPrintConfig from '@/components/jPrintConfig/jPrintConfig'

// crud交由presenter持有
const defaultCrud = CRUD({
  title: '盘点单',
  url: 'api/wareCheck',
  name:'wareCheck',
  sort: 'id,desc',
  optShow: {
    add: false,
    edit: false,
    del: true,
    download: false,
    print: true, // 打印
    printDetail: true, // 打印详情
    upload: false,
    leadingIn: true,
    search: true
  },
  query:{
    orderStatus: 'SAVE'
  },
  crudMethod: {...crudwareCheck}
})
const defaultData = {
  id: null,
  userId: null,
  warehouseId: null,
  goodsBrandIds: null,
  isAllWarehouseCheck: null,
  isBatchCheck: null
}
export default {
  name: 'wareCheck',
  components: {
    pagination,
    crudOperation,
    rrOperation,
    udOperation,
    MaterialList,
    Treeselect,
    jTableColumnConfig,
    jPrintConfig
  },
  mixins: [presenter(defaultCrud), header(), form(defaultData), crud(),publicListKey,tablemixins],
  dicts: ['order_status', 'ware_check_source_type','common_yes_or_no','t_ware_check_type','t_ware_check_source_type','common_order_status','t_ware_check_type'],
  data() {
    return {
      multiple: true,
      permission: {
        add: ['admin', 'wareCheck:add'],
        edit: ['admin', 'wareCheck:edit'],
        del: ['admin', 'wareCheck:del'],
        enable: ['admin', 'wareCheck:enable'],
        disable: ['admin', 'wareCheck:disable'],
        pass: ['admin', 'wareCheck:pass'],
        reject: ['admin', 'wareCheck:reject'],
        closed: ['admin', 'wareCheck:closed'],
        invalid: ['admin', 'wareCheck:invalid'],
        stop: ['admin', 'wareCheck:stop'],
        recover: ['admin', 'wareCheck:recover'],
        upload: ['admin', 'wareCheck:upload'],
        download: ['admin', 'wareCheck:download'],
        copy: ['admin', 'wareCheck:copy'],
        notice: ['admin', 'wareCheck:notice'],
        isReturn: ['admin', 'wareCheck:isReturn'],
        import: ['admin', 'wareCheck:import'],
        export: ['admin', 'wareCheck:export'],
        orderMerge: ['admin', 'wareCheck:orderMerge']
      },
      rules: {
        warehouseId: [
          {required: true, message: '仓库不能为空', trigger: 'blur'}
        ],
        // userId: [
        //   {required: true, message: '盘点人员不能为空', trigger: 'blur'}
        // ],
        // productTypeId: [
        //   {required: true, message: '产品分类不能为空', trigger: 'blur'}
        // ]
      },
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      dialogVisible: false,
      typeList: []
    }
  },
  watch: {
    goodsTypeIds(n){
      if (!n.length){
        this.query.goodsTypeIds = null
      }
    },
  },
  updated() {
    this.$nextTick(() => {
      this.$refs.table.doLayout()
    })
  },
  created() {
  },
  methods: {
    changeForm(){
      if(this.form.isAllWarehouseCheck == 1){
        this.form.goodsBrandIds = ''
        this.form.userId = ''
        this.form.goodsTypeId = ''
      }
      console.log('changeForm',this.form.isAllWarehouseCheck)
    },
    print(val){
      if(val !== null){
        this.pringDialog=false
        localStorage.setItem(this.invoiceType,val)
        this.crud.doPrint(val,this.printIds,this.isPreview,this.invoiceType)
      }else {
        this.$message.error('请选择打印模板');
      }
    },
    handleClick(){
      this.getTypeList()
      this.dialogVisible=true
    },
    handleCancel(){
      this.dialogVisible= false
      this.form={
        id: null,
        userId: null,
        warehouseId: null,
        goodsBrandIds: null,
        isAllWarehouseCheck: null,
        isBatchCheck: null
      }
    },
    getgoodsType(node){
      this.form.goodsTypeIds = this.crud.getNode(node,this.query.goodsTypeIds || '')
    },
    normalizer(node) {
      //去掉children=[]的children属性
      if (node.children == null || node.children.length == 0) {
        delete node.children;
      }
      return {
        id: node.id,
        label: node.name,
        children: node.children
      }
    },
    // 获取数据前设置好接口地址
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }, // 新增与编辑前做的操作
    [CRUD.HOOK.afterToCU](crud, form) {
    },
    submit() {
      crudwareCheck.addDirect(this.crud.form).then(res => {
        this.crud.resetForm()
        this.crud.toQuery()
        this.crud.cancelCU()
        this.crud.addSuccessNotify()
      })
    },
    getTypeList() {
      getTypeList({page: 0, size: 999}).then(res => {
        console.log('      this.getTypeList()',res)
        this.typeList = res
      })
    },
    getValue(e){
      this.query.startTime =this.query.dataExtent[0]
      this.query.endTime =this.query.dataExtent[1]
    },
    // 直接新增
    addDirect() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          const formdata = this.$refs.form.model
          crudwareCheck.addDirect(formdata).then(res => {
            Notification.success({
              title: '新增成功',
              duration: 500
            })
            this.dialogVisible = false
            this.crud.refresh()
          })
        }
      })
    },
    orderMerge(){
      crudwareCheck.orderMerge({orderIds:this.crud.selections.map(item=>item.id).join(',')}).then(res=>{
        if (res.status === 200){
          this.$message.success('操作成功')
          this.crud.refresh()
        }
      })
    }
  }
}

</script>
